<h1><?php echo sprintf($this->translate('view:edit:title'), $this->page->title) ?></h1>

<p><a href="<?php echo Cms_Url::pageEditUrl($this->page->id) ?>"><?php echo $this->translate('page properties') ?></a>
 | <a href="<?php echo Cms_Url::pageAddUrl() ?>"><?php echo $this->translate('add page') ?></a>
 | <a href="<?php echo Cms_Url::pageCutUrl($this->page->id) ?>"><?php echo $this->translate('move page') ?></a>
 | <a href="javascript:wsbYesNoDialog('<?php echo Cms_Url::pageDeleteUrl($this->page->id, $this->page->pid) ?>');"><?php echo $this->translate('delete page') ?></a></p>
<?php

$tabs = array();

// Tabs fuer die Sprachen erstellen
foreach($this->languages AS $language) {

    $tabs[$language->language] = '';

	$placeholders = $this->template->getPlaceholders();

    // Durch alle Platzhalter
    foreach($placeholders AS $placeholder) {
        $tabs[$language->language] .= sprintf("<b>%s (ID %d)</b> %s<br />", $placeholder->name, $placeholder->id, WSB_Controller_Url::getHtmlLink(WSB_Icon::miniconAdd(), Cms_Url::containerSelectModuleUrl($this->page->id, $placeholder->id, 0, $language->id)));

        // Parent page container
        $containers = $this->parentPageContainerSet->getContainers($language->id, $placeholder->id);
        $containersCount = count($containers);
        if($containersCount > 0) {
            foreach($containers AS $container) {
                $XT = $container->getXtInstance();
				if($XT instanceof WSB_Xtension_Base) {
					$module = $XT->getModule();
        			$title = sprintf('<div class="container-title">%s</div>', $module->name);
	            	$content = sprintf('<div class="container-content">%s</div>', $this->stripTags($XT->renderForBackend()));
        			$tabs[$language->language] .= sprintf('<div class="container-recursive">%s%s</div>', $title, $content);
				}
            }
        }

        // Page container
        $containers = $this->pageContainerSet->getContainers($language->id, $placeholder->id);
        $containersCount = count($containers);
        if($containersCount == 0) {
            $tabs[$language->language] .= '<div>-</div>';
        } else {
            $panel = new WSB_Panel();
            $panel->setContainerCount($containersCount);
            foreach($containers AS $container) {
                $XT = $container->getXtInstance();
				if($XT instanceof WSB_Xtension_Base) {
					$module = $XT->getModule();
        			$title = sprintf('<div class="container-title">%s</div>', $module->name);
	            	$content = sprintf('<div class="container-content">%s</div>', $this->stripTags($XT->renderForBackend()));
    	    		$editPanel = $panel->buildPageContainerPanel($container, $XT);
    	    		if($container->isRecursive()) {
	        			$tabs[$language->language] .= sprintf('<div class="container-recursive">%s%s%s</div>', $title, $content, $editPanel);
    	    		} else {
	        			$tabs[$language->language] .= sprintf('<div class="container">%s%s%s</div>', $title, $content, $editPanel);
    	    		}
				}
            }
        }
    }

	/*
    // Container, die einem Platzhalter zugeordnet sind, den es nicht mehr gibt im aktuellen Template
	$containers1 = $this->parentPageContainerSet->getUnassignedContainers($language->id, $placeholders);
	$containers2 = $this->pageContainerSet->getUnassignedContainers($language->id, $placeholders);
	$containers = array_merge($containers1, $containers2);
	if((count($containers) > 0)) {
		$tabs[$language->language] .= "<br /><b>Container, die keinem Platzhalter zugeordnet sind</b><br />";
	    $panel = new WSB_Panel();
	    foreach($containers AS $container) {
	        $XT = $container->getXtInstance();
			if($XT instanceof WSB_Xtension_Base) {
				$module = $XT->getModule();
				$title = sprintf('<div class="container-title">%s</div>', $module->name);
	        	$content = sprintf('<div class="container-content">%s</div>', $this->stripTags($XT->renderForBackend()));
	    		$editPanel = $panel->buildPageContainerPanel($container, $XT);
    			$tabs[$language->language] .= sprintf('<div class="container container-withou-placeholder">%s%s%s</div>', $title, $content, $editPanel);
			}
	    }
	}
	*/

}

echo $this->jsTab($tabs);

?>